<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <canvas id="c" width="400" height="300" style="border: 1px solid #ccc"></canvas>

        <script>
            const cnv = document.getElementById('c');
            const ctx = cnv.getContext('2d');
            const image = new Image();
            image.src = './image/flower.png';
            image.width = 400;
            image.height = 300;
            image.onload = () => {
                let { width, height } = image;
                // drawImage(image, dx, dy, dw, dh)
                ctx.drawImage(image, 0, 0, 400, 300);
                ctx.font = 'bold 16px serif';
                ctx.fillStyle = 'rgba(255, 255, 255, 0.4)';
                ctx.textAlign = 'center';

                const interval = 70;
                ctx.rotate((-Math.PI / 180) * 20);

                for (let x = 0; x < width; x += interval) {
                    for (let y = 0; y < height; y += interval) {
                        ctx.fillText('water', x - interval, y + interval);
                        ctx.fillText('water', 0, 0);
                    }
                }

                // drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh)
                // ctx.drawImage(image, 0, 0, 200, 200, 100, 100, 100, 100)
            };
        </script>
    </body>
</html>
